﻿@model example1.Models.Home.IndexViewModel
@{
    ViewBag.Title = "Index";
}

<h2>Index</h2>

@using (Html.BeginForm())
{
 
    <div id="accCustomers">
        @{ int i = 0; }
        @foreach (var item in Model.MobileInternetDevices)
        { 
       
            <h3><a href="#">@item.GsmNr </a></h3>
            <div>
                <p>
                    GSM :
                </p>
                <p>
                    @{ var name = "MobileInternetDevices[" + i + "].GsmNr";}
                    <input  id ="@name"  type="text" value="@item.GsmNr"  name ="@name"/>
                </p>
            </div>
       
            i++;

        }

    </div>

    <input type="button" name="add" value="Add gsm" id="addGsmButton" />

    <input type="submit" name="add" value="submit" id="submitButton" />

}

@section scripts
{
    <script type="text/javascript">

        $(document).ready(function () {

            $("#accCustomers").accordion();

            $("#addGsmButton").click(function () {

                var h3 = '<h3><a href="#"> 123333 </a></h3>';
                var div = '<div> gsm 123333</div>';
                var newGsm = $(h3 + div);

                $("#accCustomers").append(newGsm);

                $("#accCustomers").accordion('destroy');

                $("#accCustomers").accordion();
            });

        });
    </script>
}
